package com.yonyou.marketing.app.api.service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.apache.log4j.Logger;
import org.marketing.common.Response;
import org.marketing.common.dto.information.ActivityInfoDto;
import org.marketing.common.dto.information.ActivityItemsDto;
import org.marketing.common.dto.information.ActivityRecordDto;
import org.marketing.common.dto.information.ReadingDto;
import org.marketing.common.dto.leads.ThreadcarDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageInfo;
import com.yonyou.marketing.app.api.dao.TmCarOwnerMapper;
import com.yonyou.marketing.app.api.model.TmCarKnowledges;

@Service("appInformationService")
public class AppInformationService {

	private Logger          logger = Logger.getLogger(AppInformationService.class);
	
	@Autowired
    private InformationServiceInterface    informationServiceInterface;
	@Autowired
	private TmCarOwnerMapper tmCarOwnerMapper;
	
	public PageInfo<TmCarKnowledges> findCarKnow(Integer pageNum,Integer pageSize,String title) {
		logger.info("调用优惠券服务  SERVICE-INFORMATION==>start...");
		Response<PageInfo<TmCarKnowledges>> list = informationServiceInterface.findCarKnow(pageNum,
				pageSize, title);
		
		return list.getData();
	}
	public List<TmCarKnowledges> findCarKnowDetail(Integer ckId) {
		logger.info("调用优惠券服务  SERVICE-INFORMATION==>start...");
		Response<List<TmCarKnowledges>> list = informationServiceInterface.findCarKnowDetail(ckId);
		
		return list.getData();
	}
	
	public Map<String, Object> getNewsActivityContent(Integer naiId,Integer type) {
		logger.info("调用资讯服务  SERVICE-INFORMATION==>start...");
		Map<String, Object> map = informationServiceInterface.getNewsActivityContent(naiId,type);
		
		return map;
	}
	
	public Map<String, Object> saveCapitalInfor(ThreadcarDto threadcarDto) {
		Integer potentialId = tmCarOwnerMapper.selectPotentialIdByUserId(threadcarDto.getUserId());
		threadcarDto.setUserId(Long.valueOf(potentialId.toString()));
		logger.info("调用资讯服务  SERVICE-INFORMATION==>start...");
		Map<String, Object> map = informationServiceInterface.saveCapitalInfor(threadcarDto);
		
		return map;
	}
	
	public List<ActivityItemsDto> getActivityItems(Long naiId) {
		logger.info("调用资讯服务  SERVICE-INFORMATION==>start...");
		List<ActivityItemsDto> list = informationServiceInterface.getActivityItems(naiId);
		
		return list;
	}
	
	public Map<String, Object> insertPotentialUser(ActivityRecordDto activityRecordDto) {
//		Integer potentialId = tmCarOwnerMapper.selectPotentialIdByUserId(threadcarDto.getUserId());
//		threadcarDto.setUserId(Long.valueOf(potentialId.toString()));
		logger.info("调用资讯服务  SERVICE-INFORMATION==>start...");
		Map<String, Object> map = informationServiceInterface.insertPotentialUser(activityRecordDto);
		
		return map;
	}
	public Map<String, Object> saveReadingNum(ReadingDto readingDto) {
		logger.info("调用资讯服务  SERVICE-INFORMATION==>start...");
		Map<String, Object> map = informationServiceInterface.saveReadingNum(readingDto);
		
		return map;
	}
	public Map<String, Object> sendTicket(ReadingDto readingDto) {
		logger.info("调用资讯服务  SERVICE-INFORMATION==>start...");
		Map<String, Object> map = informationServiceInterface.sendTicket(readingDto);
		
		return map;
	}
	public List<ActivityRecordDto> getActivityList(String userId) {
		logger.info("调用资讯服务  SERVICE-INFORMATION==>start...");
		List<ActivityRecordDto> list = new ArrayList<>();
		list = informationServiceInterface.getActivityList(userId);
		
		return list;
	}
	public List<ActivityRecordDto> getActivityInfo(Long applyId) {
		logger.info("调用资讯服务  SERVICE-INFORMATION==>start...");
		List<ActivityRecordDto> list = new ArrayList<>();
		list = informationServiceInterface.getActivityInfo(applyId);
		
		return list;
	}
	public List<ActivityInfoDto> getMyNews(String userId,Long activityType) {
		logger.info("调用资讯服务  SERVICE-INFORMATION==>start...");
		List<ActivityInfoDto> list = new ArrayList<>();
		list = informationServiceInterface.getMyNews(userId,activityType);
		
		return list;
	}
	public List<ActivityInfoDto> getMyActivities(String userId) {
		logger.info("调用资讯服务  SERVICE-INFORMATION==>start...");
		List<ActivityInfoDto> list = new ArrayList<>();
		list = informationServiceInterface.getMyActivities(userId);
		
		return list;
	}
}
